package com.toocms.jinjuhang.ui.mine.contact_us

import android.app.Application
import android.os.Bundle
import androidx.databinding.ObservableArrayList
import androidx.databinding.ObservableField
import com.blankj.utilcode.util.StringUtils
import com.toocms.jinjuhang.BR
import com.toocms.jinjuhang.R
import com.toocms.jinjuhang.config.Constants
import com.toocms.tab.base.BaseModel
import com.toocms.tab.base.BaseViewModel
import com.toocms.tab.binding.ItemBinding
import com.toocms.tab.binding.command.BindingAction
import com.toocms.tab.binding.command.BindingCommand

class ContactUsModel(application: Application, bundle: Bundle?) :
    BaseViewModel<BaseModel>(application) {

    val titleObservableField by lazy {
        val title = bundle?.getString(Constants.BundleKey.KEY_TITLE)
            ?: StringUtils.getString(R.string.str_contact_us)
        ObservableField(title)
    }

    val backClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        finishFragment()
    })

    val items = ObservableArrayList<ContactUsItemModel>()
    val itemBinding = ItemBinding.of<ContactUsItemModel>(
        BR.contactUsItemModel,
        R.layout.item_contact_us
    )

    init {
        items += ContactUsItemModel(
            this,
            ObservableField("客服热线"),
            arrayListOf(
                ContactUsTelItem("服务热线", "17602273099", "(微信同号)"),
                ContactUsTelItem("技术服务", "18902131627", "(微信同号)"),
                ContactUsTelItem("服务费补助咨询", "15620869871", "(微信同号)"),
                ContactUsTelItem("健康咨询", "华盟直播间")
            )
        )
        items += ContactUsItemModel(
            this,
            ObservableField("外联部"),
            arrayListOf(
                ContactUsTelItem("指导老师 陈丽萍", "13389062539", "(微信同号)"),
                ContactUsTelItem("指导老师 高健", "13389052287", "(微信同号)"),
                ContactUsTelItem("指导老师 吴桐", "15332163857", "(微信同号)"),
                ContactUsTelItem("指导老师 荣军", "15522180025", "(微信同号)"),
                ContactUsTelItem("捐赠咨询", "17627823868", "(微信同号)")
            )
        )
    }
}